package cn.com.huzo.repository.trade.impl;

import cn.com.huzo.model.entities.trade.ProductionInstructionLinesDestinationSchemaEntity;
import cn.com.huzo.repository.trade.ProductionInstructionLinesDestinationSchemaRepository;
import huzofw.repository.impl.GenericRepositoryImpl;
import huzofw.repository.impl.MyBatisDaoUtils;
import java.util.List;
import java.util.Map;
import org.springframework.stereotype.Repository;

/**
 * 生产指示书明细-发货目的地数据访问对象。
 *
 * @author 吴旭
 */
@Repository("ProductionInstructionLinesDestinationSchemaRepository")
public class ProductionInstructionLinesDestinationSchemaRepositoryImpl
        extends GenericRepositoryImpl<ProductionInstructionLinesDestinationSchemaEntity, String>
        implements ProductionInstructionLinesDestinationSchemaRepository {

    private final String namespace = "cn.com.huzo.repository.trade.ProductionInstructionLinesDestinationSchemaRepository";

    /**
     * 构造函数,设置the instance to ProductRepositoryImpl.class.
     */
    public ProductionInstructionLinesDestinationSchemaRepositoryImpl() {
        super(ProductionInstructionLinesDestinationSchemaEntity.class);
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public List<ProductionInstructionLinesDestinationSchemaEntity> fetchByHeaderId(Long headerId) {
        return getSqlSession().selectList(MyBatisDaoUtils.getMapperQueryId(
                namespace, "fetchByHeaderId"), headerId);
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public String insert(ProductionInstructionLinesDestinationSchemaEntity instance) {
        getSqlSession().insert(MyBatisDaoUtils.getMapperQueryId(
                namespace, "insert"), instance);
        // 返回保存后的记录ID
        return instance.getLinesId();
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public Integer insertByNewLines(Long headerId) {
        return getSqlSession().insert(MyBatisDaoUtils.getMapperQueryId(
                namespace, "insertByNewLines"), headerId);
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public Integer update(ProductionInstructionLinesDestinationSchemaEntity instance) {
        return getSqlSession().insert(MyBatisDaoUtils.getMapperQueryId(
                namespace, "update"), instance);
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public Integer fetchForCountForDestination(Long headerId) {
        return getSqlSession().selectOne(MyBatisDaoUtils.getMapperQueryId(
                namespace, "fetchForCountForDestination"), headerId);
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public Integer insertDestination(Map<String, Object> criterion) {
        return getSqlSession().insert(MyBatisDaoUtils.getMapperQueryId(
                namespace, "insertDestination"), criterion);
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public List<String> fetchScheduleDateNode(Long headerId) {
        return getSqlSession().selectList(MyBatisDaoUtils.getMapperQueryId(
                namespace, "fetchScheduleDateNode"), headerId);
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public Integer insertDeliveryDate(Map<String, Object> criterion) {
        return getSqlSession().insert(MyBatisDaoUtils.getMapperQueryId(
                namespace, "insertDeliveryDate"), criterion);
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public Integer updateDeliveryDate(Map<String, Object> criterion) {
        return getSqlSession().update(MyBatisDaoUtils.getMapperQueryId(
                namespace, "updateDeliveryDate"), criterion);
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public Integer deleteDeliveryDate(Map<String, Object> criterion) {
        return getSqlSession().delete(MyBatisDaoUtils.getMapperQueryId(
                namespace, "deleteDeliveryDate"), criterion);
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public Integer deleteByNullDestination(Long headerId) {
        return getSqlSession().delete(MyBatisDaoUtils.getMapperQueryId(
                namespace, "deleteByNullDestination"), headerId);
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public Integer deleteByParentLinesId(String parentLinesId) {
        return getSqlSession().delete(MyBatisDaoUtils.getMapperQueryId(
                namespace, "deleteByParentLinesId"), parentLinesId);
    }
}
